package pro.softzhang.algo.lc;

import pro.softzhang.algo.flag.book.BOfferII;
import pro.softzhang.algo.flag.difficulty.DYellow;
import pro.softzhang.algo.flag.knowledge.KQueue;
import pro.softzhang.algo.flag.knowledge.KStack;
import pro.softzhang.algo.flag.theme.TDesign;

import java.util.Stack;

@KQueue
@KStack
@BOfferII(9)
@TDesign
@DYellow
public class TwoStacksQueue {
    public static void main(String[] args) {

    }

    static class CQueue {
        private Stack<Integer> s1 = new Stack<>(), s2 = new Stack<>();

        public CQueue() {}

        public void appendTail(int value) {
            s1.push(value);
        }

        public int deleteHead() {
            if (!s2.isEmpty()) {
                return s2.pop();
            }

            while (s1.size() > 0) {
                s2.push(s1.pop());
            }

            return s2.isEmpty() ? -1 : s2.pop();
        }
    }
}
